package com.ruoyi.shangpinxinxi.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.shangpinxinxi.domain.Shangpinxinxi2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shangpinxinxi.mapper.ShangpinxinxiMapper;
import com.ruoyi.shangpinxinxi.domain.Shangpinxinxi;
import com.ruoyi.shangpinxinxi.service.IShangpinxinxiService;
import com.ruoyi.common.core.text.Convert;

/**
 * 商品信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-05-05
 */
@Service
public class ShangpinxinxiServiceImpl implements IShangpinxinxiService 
{
    @Autowired
    private ShangpinxinxiMapper shangpinxinxiMapper;

    /**
     * 查询商品信息
     * 
     * @param id 商品信息主键
     * @return 商品信息
     */
    @Override
    public Shangpinxinxi selectShangpinxinxiById(Long id)
    {
        return shangpinxinxiMapper.selectShangpinxinxiById(id);
    }

    /**
     * 查询商品信息列表
     * 
     * @param shangpinxinxi 商品信息
     * @return 商品信息
     */
    @Override
    public List<Shangpinxinxi> selectShangpinxinxiList(Shangpinxinxi shangpinxinxi)
    {
        return shangpinxinxiMapper.selectShangpinxinxiList(shangpinxinxi);
    }

    /**
     * 新增商品信息
     * 
     * @param shangpinxinxi 商品信息
     * @return 结果
     */
    @Override
    public int insertShangpinxinxi(Shangpinxinxi shangpinxinxi)
    {
        return shangpinxinxiMapper.insertShangpinxinxi(shangpinxinxi);
    }

    /**
     * 修改商品信息
     * 
     * @param shangpinxinxi 商品信息
     * @return 结果
     */
    @Override
    public int updateShangpinxinxi(Shangpinxinxi shangpinxinxi)
    {
        return shangpinxinxiMapper.updateShangpinxinxi(shangpinxinxi);
    }

    /**
     * 批量删除商品信息
     * 
     * @param ids 需要删除的商品信息主键
     * @return 结果
     */
    @Override
    public int deleteShangpinxinxiByIds(String ids)
    {
        return shangpinxinxiMapper.deleteShangpinxinxiByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品信息信息
     * 
     * @param id 商品信息主键
     * @return 结果
     */
    @Override
    public int deleteShangpinxinxiById(Long id)
    {
        return shangpinxinxiMapper.deleteShangpinxinxiById(id);
    }

    @Override
    public List<Shangpinxinxi2> selectShangpinxinxiListAndQianXian(Shangpinxinxi shangpinxinxi) {
        return null;
    }

    @Override
    public Shangpinxinxi selectShangpinxinxiByBianHao(String shangpinId) {
        return null;
    }

    @Override
    public List<Shangpinxinxi> selectGoods4LeiBie() {
        List<Shangpinxinxi> goodsList = new ArrayList<>();
        List<String> leibeilist = shangpinxinxiMapper.selectGoods4LeiBie();
        for (String s:leibeilist) {
            Shangpinxinxi goods = new Shangpinxinxi();
            goods.setShangpinLeibie(s);
            goodsList.add(goods);
        }
        return goodsList;
    }

    @Override
    public List<Shangpinxinxi> selectGoods4LeiBieAndName() {
        List<Shangpinxinxi> goodsList = shangpinxinxiMapper.selectGoods4LeiBieAndName();
        return goodsList;
    }
}
